package com.youkeyi.ddy.cloud.common.utils;

import java.util.Date;
import java.util.Random;
import java.util.UUID;

/**
 * <p>
 * 简单UUID生成器
 * </p>
 *
 * @author 23.1
 * @since 2020-05-11
 */
public class SimpleUUidUtils {
    private static final String DICT = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    private static final Random random = new Random();

    /**
     * UUID生成器
     *
     * @return
     */
    public synchronized static String getUuid() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }

    /**
     * 数字UUID（验证码）生成器
     *
     * @return
     */
    public synchronized static Long getInvidID() {
        Random rand = new Random();//生成随机数
        String cardNnumer = "";
        for (int a = 0; a < 6; a++) {
            cardNnumer += rand.nextInt(10);//生成6位数字
        }
        return Long.parseLong(new Date().getTime() + cardNnumer);
    }

    /**
     * 数字UUID（验证码）生成器
     *
     * @return
     */
    public synchronized static Long getInvidID(int length) {
        Random rand = new Random();//生成随机数
        String cardNnumer = "";
        for (int a = 0; a < length; a++) {
            cardNnumer += rand.nextInt(10);//生成6位数字
        }
        return Long.parseLong(new Date().getTime() + cardNnumer);
    }
}
